//
//  TCLYLoginModel.m
//  YuErmuYing
//
//  Created by LYang on 16/9/13.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYLoginModel.h"
#import "HttpRequest.h"

@implementation TCLYLoginModel
//登录 判断账号密码正确性的接口
-(void)judgeLoginParameter:(NSDictionary *) parameter{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/login/login";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameter success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.loginStr = json[@"msg"];
        self.userIdStr = json[@"data"];
        NSLog(@"登录%@",json);
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"judgeLogin" object:self];
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];

}
//注册的接口
-(void)registeredLoginParameter:(NSDictionary *)parameter{
    NSString * urlStr = @"http://112.74.114.1/Parenting/index.php/api/login/register";
    HttpRequest * httpRequest = [HttpRequest sharedInstance];
    [httpRequest postWithURLString:urlStr parameters:parameter success:^(id responseObject) {
        id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        self.loginStr = json[@"msg"];
        NSLog(@"注册%@",json);
        [[NSNotificationCenter defaultCenter] postNotificationName:@"registeredLogin" object:self];
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
@end
